<template>
  <div>
    <div class="title">
      <el-row :gutter="20">
        <el-col :span="24" :offset="0">
          申报批次管理
        </el-col>
        <el-col :span="12" :offset="0">
          <div class="right">
            <!-- <el-button type="success" size="mini" @click="clearLimit" :loading="loading">清空项目复制限制</el-button> -->
          </div>
        </el-col>
      </el-row>
    </div>
    <!-- <el-tag type="info" size="normal">每年运维项目只能复制一次，点击“清空项目复制限制”按钮解除复制限制</el-tag> -->
    <div class="container">
      <el-form :model="dateList" ref="dateList" label-position="top" :inline="false" size="normal">
        <el-form-item label="运维申报批次：">
          <el-date-picker v-model="dateList.apply_batch" type="year" value-format="yyyy" size="normal"
            :picker-options="pickerOptions" :clearable="false" placeholder="选择运维申报批次：" class="wid">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="申报开始时间：">
          <el-date-picker v-model="dateList.infoStartTime" type="date" value-format="yyyy-MM-dd" size="normal"
            :picker-options="pickerOptions" :clearable="false" placeholder="选择运维开始时间" class="wid">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="申报结束时间：">
          <el-date-picker v-model="dateList.infoEndTime" type="date" value-format="yyyy-MM-dd" size="normal"
            :picker-options="pickerOptions" :clearable="false" placeholder="选择运维结束时间" class="wid">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审核结束时间：">
          <el-date-picker v-model="dateList.shEndTime" type="date" value-format="yyyy-MM-dd" size="normal"
            :picker-options="pickerOptions" :clearable="false" placeholder="审核结束时间" class="wid">
          </el-date-picker>
        </el-form-item>
        <div class="center">
          <el-button type="primary" size="default" @click="submit" :loading="loading">更新</el-button>
          <el-button type="green" size="default" @click="onAdd" :loading="loading">同步</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  name: 'OperaTotal',
  components: {

  },
  props: {

  },
  data () {
    return {
      loading: false,
      dateList: {},
      pickerOptions: {
        // disabledDate (time) {
        //   let now = new Date()
        //   return time.getFullYear() < now.getFullYear()
        // },
      }
    }
  },
  created () {

  },
  mounted () {
    this.init()
  },
  methods: {
    async init () {
      this.loading = true
      const res = await this.$http('sysApplyDate', {
        source: '0'
      })
      // 好家伙，返回个字符串的null值
      for (let name in res) {
        if (!res[name] || res[name] == 'null') {
          delete res[name]
        }
      }
      this.dateList = res
      this.loading = false
    },
    async clearLimit () {
      this.loading = true
      const res = await this.$http('sysProjectLimit', {
      })
      this.$tips.success(res.errmsg)
      this.loading = false
    },
    async onAdd () {
      this.loading = true
      const res = await this.$http('sysApplyDateAdd', {
        ...this.dateList
      })
      this.$tips.success(res.errmsg)
      this.loading = false
    },
    async submit () {
      this.loading = true
      const res = await this.$http('sysApplyDateUp', {
        ...this.dateList
      })
      this.$tips.success(res.errmsg)
      this.loading = false
    }
  },
  computed: {

  }
}
</script>
<style lang='scss' scoped>
</style>
